'   W r i t t e n   b y   C r a i g ' n ' D a v e 
 
 M o d u l e   M o d u l e 1 
 
         '   M e r g e   s o r t   u s i n g   r e c u r s i o n   m e t h o d   1 
 
         '   T h i s   v e r s i o n   i s   t h e   c l a s s i c   i m p l e m e n t a t i o n 
 
         F u n c t i o n   m e r g e _ s o r t ( i t e m s ( )   A s   S t r i n g ) 
 
                 '   S p l i t   s t e p 
 
                 I f   i t e m s . C o u n t   >   1   T h e n 
 
                         D i m   m i d   A s   I n t e g e r   =   i t e m s . C o u n t   \   2 
 
                         D i m   a r r a y 1 ( )   A s   S t r i n g   =   i t e m s . S k i p ( 0 ) . T a k e ( m i d ) . T o A r r a y 
 
                         D i m   a r r a y 2 ( )   A s   S t r i n g   =   i t e m s . S k i p ( m i d ) . T a k e ( i t e m s . C o u n t   -   m i d ) . T o A r r a y 
 
 
 
                         m e r g e _ s o r t ( a r r a y 1 ) 
 
                         m e r g e _ s o r t ( a r r a y 2 ) 
 
 
 
                         D i m   i n d e x 1   A s   I n t e g e r   =   0 
 
                         D i m   i n d e x 2   A s   I n t e g e r   =   0 
 
                         D i m   i t e m s _ i n d e x   A s   I n t e g e r   =   0 
 
 
 
                         '   M e r g e   s t e p 
 
                         D o   W h i l e   i n d e x 1   <   a r r a y 1 . C o u n t   A n d   i n d e x 2   <   a r r a y 2 . C o u n t 
 
                                 '   C h e c k   e a c h   i t e m   i n   e a c h   l i s t ,   a n d   a d d   t h e   s m a l l e s t   i t e m   t o   a   n e w   l i s t 
 
                                 I f   a r r a y 1 ( i n d e x 1 )   <   a r r a y 2 ( i n d e x 2 )   T h e n 
 
                                         i t e m s ( i t e m s _ i n d e x )   =   a r r a y 1 ( i n d e x 1 ) 
 
                                         i n d e x 1   =   i n d e x 1   +   1 
 
                                 E l s e 
 
                                         i t e m s ( i t e m s _ i n d e x )   =   a r r a y 2 ( i n d e x 2 ) 
 
                                         i n d e x 2   =   i n d e x 2   +   1 
 
                                 E n d   I f 
 
                                 i t e m s _ i n d e x   =   i t e m s _ i n d e x   +   1 
 
                         L o o p 
 
 
 
                         '   A d d   l e f t   o v e r   i t e m s   f r o m   t h e   r e m a i n i n g   l i s t 
 
                         D o   W h i l e   i n d e x 1   <   a r r a y 1 . C o u n t 
 
                                 i t e m s ( i t e m s _ i n d e x )   =   a r r a y 1 ( i n d e x 1 ) 
 
                                 i n d e x 1   =   i n d e x 1   +   1 
 
                                 i t e m s _ i n d e x   =   i t e m s _ i n d e x   +   1 
 
                         L o o p 
 
 
 
                         D o   W h i l e   i n d e x 2   <   a r r a y 2 . C o u n t 
 
                                 i t e m s ( i t e m s _ i n d e x )   =   a r r a y 2 ( i n d e x 2 ) 
 
                                 i n d e x 2   =   i n d e x 2   +   1 
 
                                 i t e m s _ i n d e x   =   i t e m s _ i n d e x   +   1 
 
                         L o o p 
 
                 E n d   I f 
 
                 R e t u r n   i t e m s 
 
         E n d   F u n c t i o n 
 
 
 
         '   M a i n   a l g o r i t h m   s t a r t s   h e r e 
 
         S u b   M a i n ( ) 
 
                 D i m   i t e m s ( )   A s   S t r i n g   =   { " F l o r i d a " ,   " G e o r g i a " ,   " D e l a w a r e " ,   " A l a b a m a " ,   " C a l i f o r n i a " } 
 
                 i t e m s   =   m e r g e _ s o r t ( i t e m s ) 
 
                 C o n s o l e . W r i t e L i n e ( S t r i n g . J o i n ( " ,   " ,   i t e m s ) ) 
 
         E n d   S u b 
 
 E n d   M o d u l e 
 
 